package com.itheima;
import java.util.*;

public class CollectionsDemo {
    public static void main(String[] args) {
        test1();
    }

    private static void test0() {
        List<String> list = new LinkedList<>();
        Collections.addAll(list,"张三","王五","赵六","李四");
        list.forEach(System.out::println);
        System.out.println("--------------------------------------");
        //打乱顺序
        Collections.shuffle(list);
        list.forEach(System.out::println);
    }

    public static void test1() {
        List<Integer> list = new ArrayList<>();
        Collections.addAll(list,1,2,3,4,5,6,7,8,9,10);
        //按照倒序排序
        Collections.sort(list);
        list.forEach(System.out::println);
        Collections.sort(list,(o1, o2)->{
            return o2-o1;
        });
        System.out.println("--------------------------------------");
        list.forEach(System.out::println);
        //让学生类实现Comparable接口
        List<Student> students = new ArrayList<>();
        students.add(new Student("张三", 26));
        students.add(new Student("王五", 9));
        students.add(new Student("赵六", 28));
        Collections.sort(students);
        students.forEach(System.out::println);
    }
}